class Paddle extends Sprite {
    constructor(dir, x, y) {
        super(dir, 'images/paddle.png', x, y)
        this.speed = 10
    }
    move(x) {
        if (x > 400 - this.w) {
            x = 400 - this.w
        }
        else if (x < 0) {
            x = 0
        }
        this.x = x

    }
    moveLeft() {
        this.move(this.x - this.speed)
    }
    moveRight() {
        this.move(this.x + this.speed)
    }
    collide(ball) {
        var a = this
        var b = ball
        if (aInb(a.x, b.x, b.x + b.w) || aInb(b.x, a.x, a.x + a.w)) {
            if (aInb(a.y, b.y, b.y + b.h) || aInb(b.y, a.y, a.y + a.h)) {
                return true
            }
        }
        return false
    }
}